package client.comm.baoding

import android.content.Intent
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import client.comm.baoding.ui.GoodsOrderActivity

class AliPayBackActivity : AppCompatActivity() {
    public override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)


        intent?.let {
            intent.data?.let {
                val payCode = it.getQueryParameter("payCode")
                Log.d("DDD", "${payCode}")

                when (payCode) {
                    "2" -> {
                        startActivity(Intent(this, GoodsOrderActivity::class.java).apply {
                            putExtra("index", 2)
                            putExtra("msg", "支付成功")
                        })
                        sendBroadcast(Intent("ccsdgsdgs"))
                        finish()
                    }
                    else -> {
                        startActivity(Intent(this, GoodsOrderActivity::class.java).apply {
                            putExtra("index", 1)
                            putExtra("msg", "支付失败")
                        })
                        sendBroadcast(Intent("ccsdgsdgs"))
                        finish()
                    }
                }
            }
        }
    }

    override fun onNewIntent(intent: Intent) {
        super.onNewIntent(intent)

        intent?.let {
            intent.data?.let {
                val payCode = it.getQueryParameter("payCode")
                when (payCode) {
                    "2" -> {
                        startActivity(Intent(this, GoodsOrderActivity::class.java).apply {
                            putExtra("index", 2)
                            putExtra("msg", "支付成功")
                        })
                        sendBroadcast(Intent("ccsdgsdgs"))
                        finish()
                    }
                    else -> {
                        startActivity(Intent(this, GoodsOrderActivity::class.java).apply {
                            putExtra("index", 1)
                            putExtra("msg", "支付失败")
                        })
                        sendBroadcast(Intent("ccsdgsdgs"))

                        finish()
                    }
                }
            }
        }
    }
}